package com.huang.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Aspect
@Order
@Component
public class MyAop {

	@Pointcut("execution(* com.huang.aop.MyCalculate.*(..))")
	public void pointcut(){}

	@Before(value = "pointcut()")
	public void methodBefore(JoinPoint joinPoint){
		String name = joinPoint.getSignature().getName();
		System.out.println("<before>执行方法" +name+ " 参数" + Arrays.asList(joinPoint.getArgs()));
	}

	@After(value = "pointcut()")
	public void methodBefore2(JoinPoint joinPoint){
		String name = joinPoint.getSignature().getName();
		System.out.println("《after》执行方法" +name+ " 参数" + Arrays.asList(joinPoint.getArgs()));
	}

	@AfterReturning(value = "pointcut()")
	public void methodBefore3(JoinPoint joinPoint){
		String name = joinPoint.getSignature().getName();
		System.out.println("《return》执行方法" +name+ " 参数" + Arrays.asList(joinPoint.getArgs()));
	}

	@AfterThrowing(value = "pointcut()")
	public void methodBefore4(JoinPoint joinPoint){
		String name = joinPoint.getSignature().getName();
		System.out.println("《exception》执行方法" +name+ " 参数" + Arrays.asList(joinPoint.getArgs()));
	}

}
